<?php
/*
 * Cuatroxl
 *
 * LICENSE
 *
 * This file is part of Cuatroxl ( http://code.google.com/p/cuatroxl/ ).
 *
 * Cuatroxl is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Cuatroxl is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cuatroxl.  If not, see <http ://www.gnu.org/licenses/>.
 *
 *
 * @category   Cuatroxl
 * @package    Cuatroxl_Zf_Action_Helper
 * @autor      Jimmy Collazos <jimmy.collazos@gmail.com>
 * @license    http://www.gnu.org/licenses/gpl.html     GPLv3
 * @version    0.01
 */


/**
 * @see Zend_Controller_Plugin_Abstract
 */
require_once 'Zend/Controller/Plugin/Abstract.php';

/**
 * @category   Cuatroxl
 * @package    Cuatroxl_Controller
 * @subpackage Cuatroxl_Controller_Plugin
 * @license    http://www.gnu.org/licenses/gpl.html     GPLv3
 */
class Cuatroxl_Controller_Plugin_AjaxView extends Zend_Controller_Plugin_Abstract
{
  public function preDispatch($request)
  {
    if(!$request->isXmlHttpRequest())
      return;

    
    $oldViewHelper	= Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
    $viewHelper 	= new Zend_Controller_Action_Helper_ViewRenderer($oldViewHelper->view);

    header('Content-Type: text/x-json; charset=utf-8');
    Zend_Controller_Action_HelperBroker::addHelper($viewHelper);
  }
}